home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 101-125 / scopedisk118 / cosmicquest / human.c < prev    next >
C/C++ Source or Header  |  1995-03-19  |  46KB  |  1,704 lines

  1. extern struct NShip ship[SHIPNO];
  2. struct IntuiText DText=
  3.   {
  4.   GREENPEN,BLACKPEN,
  5.   JAM2,
  6.   0,0,
  7.   NULL,
  8.   NULL,
  9.   NULL
  10.   };
  11. struct IntuiMessage *mes;
  12. int screen1,screen2;
  13. int show1,show2;
  14. int showpla1,showpla2;
  15. int sort[STARNO],dis[STARNO],sortsta;
  16.  
  17. human(pla)
  18. int pla;
  19.   {
  20.   int i;
  21.   struct NCommand c;
  22.   c.com=DUMMY;
  23.   screen1=PLAYERSUMMARY;
  24.   screen2=CLEAR;
  25.   sortsta=-1;
  26.   if (waittime>general.time) return();
  27.   make_displ(pla);
  28.   while((c.com=input_action(0,pla))>=0)
  29.     {
  30.     switch(c.com)
  31.       {
  32.       case POSSESS:
  33.         c.par[0]=input_star(1,pla);
  34.         c.par[1]=input_planet(2,pla);
  35.         break;
  36.       case LAND:
  37.         c.par[0]=input_task(1,pla);
  38.         c.par[1]=input_planet(2,pla);
  39.         break;
  40.       case CARRY:
  41.         c.par[0]=input_task(1,pla);
  42.         input_ships_task(2,pla,&c);
  43.         break;
  44.       case DESTINATION:
  45.         c.par[0]=input_task(1,pla);
  46.         c.par[1]=input_star(2,pla);
  47.         break;
  48.       case EMIGRATION:
  49.         c.par[0]=input_star(1,pla);
  50.         c.par[1]=input_planet(2,pla);
  51.         c.par[2]=input_number(3,pla,star[c.par[0]].planet[c.par[1]].population);
  52.         break;
  53.       case JOIN:
  54.         input_many_tasks(1,pla,&c);
  55.         break;
  56.       case KILL:
  57.         c.par[0]=input_star(1,pla);
  58.         c.par[1]=input_planet_or_ret(2,pla);
  59.         break;
  60.       case SPLIT:
  61.         c.par[0]=input_task(1,pla);
  62.         input_ships_task(2,pla,&c);
  63.         break;
  64.       case PRODUCE:
  65.         c.par[0]=input_star(1,pla);
  66.         c.par[1]=input_planet(2,pla);
  67.         c.par[2]=input_product(3,pla,general.techlevel[pla]);
  68.         break;
  69.       case DECLARE:
  70.         c.par[0]=input_player(1,pla);
  71.         c.par[1]=input_status(2,pla,general.relation[pla][c.par[0]]);
  72.         break;
  73.       default:break;/*ERROR*/
  74.       }
  75.     do_command(pla,&c);
  76.     make_displ(pla);
  77.     }
  78.   }
  79. make_displ(pla)
  80. int pla;
  81.   {
  82.   mapdisplay(pla);
  83.   if (screen1==STARSUMMARY) starsummary(pla,show1);
  84.   if (screen2==TASKSUMMARY) tasksummary(pla,showpla2,show2);
  85.   if (screen1==PLAYERSUMMARY) showstatus(pla);
  86.   if (screen2==TASKOVERVIEW) showtasks(pla,showpla2,show2);
  87.   if (screen2==SHIPOVERVIEW) tshipsummary(pla,showpla2,show2);
  88.   if (screen1==STAROVERVIEW) showstars(pla);
  89.   if (screen2==SHIPSUMMARY) shipsummary(pla,show2);
  90.   if (screen2==PLANETSUMMARY) planetsummary(pla,show2,showpla2);
  91.   }
  92. input_action(line,pla)
  93. int line;
  94. int pla;
  95.   {
  96.   int c,i,j,p;
  97.   char *str;
  98.   switch(cget(pla))
  99.     {
  100. #include "debug.c" /* remove this line when recompiling */
  101.     case 'p':
  102.       str="Possess planet";
  103.       c=POSSESS;
  104.       break;
  105.     case 'G':
  106.       return(-1);
  107.     case 'c':
  108.       str="Carry ships";
  109.       c=CARRY;
  110.       break;
  111.     case 'h':
  112.       str="Hyperspace Tf";
  113.       c=DESTINATION;
  114.       break;
  115.     case 'e':
  116.       str="Emigration";
  117.       c=EMIGRATION;
  118.       break;
  119.     case 'l':
  120.       str="Land on planet";
  121.       c=LAND;
  122.       break;
  123.     case 'j':
  124.       str="Join taskforces";
  125.       c=JOIN;
  126.       break;
  127.     case 'k':
  128.       str="Kill";
  129.       c=KILL;
  130.       break;
  131.     case 'n':
  132.       str="New Taskforce from";
  133.       c=SPLIT;
  134.       break;
  135.     case 'b':
  136.       str="Build";
  137.       c=PRODUCE;
  138.       break;
  139.     case 'd':
  140.       str="Diplomacy";
  141.       c=DECLARE;
  142.       break;
  143.     case '?':
  144.       showhelp();
  145.       return(DUMMY);
  146.     case 's':
  147.       SetAPen(ConPort,BLACKPEN);
  148.       RectFill(ConPort,400L,0L,639L,39L);
  149.       DText.FrontPen=GREENPEN;
  150.       DText.IText=(UBYTE *) "SHOW  >Starsummary";
  151.       PrintIText(ConPort,&DText,400L,8L*line);
  152.       i=input_star_or_ret(1,pla);
  153.       if(i==STARNO)
  154.         {
  155.         screen1=STAROVERVIEW;
  156.         return(DUMMY);
  157.         }
  158.       j=input_planet_or_ret(2,pla);
  159.       if(j==PLANETNO)
  160.         {
  161.         screen1=STARSUMMARY;
  162.         show1=i;
  163.         showpla1=j;
  164.         return(DUMMY);
  165.         }
  166.       screen2=PLANETSUMMARY;
  167.       show2=i;
  168.       showpla2=j;
  169.       return(DUMMY);
  170.     case 't':
  171.       SetAPen(ConPort,BLACKPEN);
  172.       RectFill(ConPort,400L,0L,639L,39L);
  173.       DText.FrontPen=GREENPEN;
  174.       DText.IText=(UBYTE *) "SHOW  >Taskforcesummary";
  175.       PrintIText(ConPort,&DText,400L,8L*line);
  176.       showpla2=input_player_pref(1,pla);
  177.       show2=input_task_or_ret(2,pla);
  178.       if(show2==TASKNO) screen2=TASKOVERVIEW;
  179.                    else screen2=TASKSUMMARY;
  180.       return(DUMMY);
  181.     case 'z':
  182.       SetAPen(ConPort,BLACKPEN);
  183.       RectFill(ConPort,400L,0L,639L,39L);
  184.       DText.FrontPen=GREENPEN;
  185.       DText.IText=(UBYTE *) "SHOW  >Status";
  186.       PrintIText(ConPort,&DText,400L,8L*line);
  187.       screen1=PLAYERSUMMARY;
  188.       return(DUMMY);
  189.     case 'f':
  190.       SetAPen(ConPort,BLACKPEN);
  191.       RectFill(ConPort,400L,0L,639L,39L);
  192.       DText.FrontPen=GREENPEN;
  193.       DText.IText=(UBYTE *) "SHOW  >Shipsummary";
  194.       PrintIText(ConPort,&DText,400L,8L*line);
  195.       showpla2=input_player_or_ret(1,pla);
  196.       show2=input_ship(2,pla);
  197.       if(showpla2==PLAYERNO) screen2=SHIPSUMMARY;
  198.                         else screen2=SHIPOVERVIEW;
  199.       return(DUMMY);
  200.     default:
  201.       DisplayBeep(ConScreen);
  202.       showhelp();
  203.       return(DUMMY);
  204.     }
  205.   SetAPen(ConPort,BLACKPEN);
  206.   RectFill(ConPort,400L,0L,639L,39L);
  207.   DText.FrontPen=GREENPEN;
  208.   DText.IText=(UBYTE *) "ACTION>";
  209.   PrintIText(ConPort,&DText,400L,8L*line);
  210.   DText.IText=(UBYTE *)str;
  211.   PrintIText(ConPort,&DText,456L,8L*line);
  212.   return(c);
  213.   }
  214. input_task(line,pla)
  215. int line;
  216. int pla;
  217.   {
  218.   int c,tas;
  219.   DText.FrontPen=GREENPEN;
  220.   DText.IText=(UBYTE *) "TF    >";
  221.   PrintIText(ConPort,&DText,400L,8L*line);
  222.   tas=TASKNO+1;
  223.   while(tas>=TASKNO)
  224.     {
  225.     c=cget(pla);
  226.     if(c>='a' && c<='z') tas=c-'a';
  227.     if(c>='A' && c<='Z') tas=c-'A'+SECSET;
  228.     }
  229.   DText.IText=(UBYTE *)" ";
  230.   DText.IText[0]=(UBYTE) c;
  231.   PrintIText(ConPort,&DText,456L,8L*line);
  232.   return(tas);
  233.   }
  234. input_task_or_ret(line,pla)
  235. int line;
  236. int pla;
  237.   {
  238.   int c,tas;
  239.   DText.FrontPen=GREENPEN;
  240.   DText.IText=(UBYTE *) "TF    >";
  241.   PrintIText(ConPort,&DText,400L,8L*line);
  242.   tas=TASKNO+1;
  243.   while(tas>TASKNO)
  244.     {
  245.     c=cget(pla);
  246.     if(c>='a' && c<='z') tas=c-'a';
  247.     if(c>='A' && c<='Z') tas=c-'A'+SECSET;
  248.     if(c==0x0d) tas=TASKNO;
  249.     }
  250.   if(tas==TASKNO) return(TASKNO);
  251.   DText.IText=(UBYTE *)" ";
  252.   DText.IText[0]=(UBYTE) c;
  253.   PrintIText(ConPort,&DText,456L,8L*line);
  254.   return(tas);
  255.   }
  256. input_ships_task(line,pla,co)
  257. int line;
  258. int pla;
  259. struct NCommand *co;
  260.   {
  261.   int i,tas;
  262.   tas=co->par[0];
  263.   for(i=0;i<SHIPNO;i++)
  264.     {
  265.     co->par[i+1]=0;
  266.     if(INTASK(pla,tas,i)==0 || task[pla][tas].headed==-1) continue;
  267.     SetAPen(ConPort,BLACKPEN);
  268.     RectFill(ConPort,400L,line*8L,639L,line*8L+15);
  269.     SetAPen(ConPort,GREENPEN);
  270.     DText.IText=(UBYTE *)ship[i].name;
  271.     PrintIText(ConPort,&DText,400L,line*8L);
  272.     co->par[i+1]=input_number(line+1,pla,INTASK(pla,tas,i));
  273.     }
  274.   return();
  275.   }
  276. input_many_tasks(line,pla,co)
  277. int line;
  278. int pla;
  279. struct NCommand *co;
  280.   {
  281.   int c,i;
  282.   i=0;
  283.   DText.FrontPen=GREENPEN;
  284.   DText.IText=(UBYTE *) "TFS   >";
  285.   PrintIText(ConPort,&DText,400L,8L*line);
  286.   DText.IText=(UBYTE *)" ";
  287.   while(1)
  288.     {
  289.     c=cget(pla);
  290.     if(c==0x0d)
  291.       {
  292.       co->par[i]=TASKNO;
  293.       break;
  294.       }
  295.     if(c>='a' && c<='z' && c-'a'<TASKNO)
  296.       {
  297.       co->par[i]=c-'a';
  298.       DText.IText[0]=(UBYTE) c;
  299.       PrintIText(ConPort,&DText,456L+8L*i,8L*line);
  300.       i++;
  301.       }
  302.     if(c>='A' && c<='Z' && c-'A'+SECSET<TASKNO)
  303.       {
  304.       co->par[i]=c-'A'+SECSET;
  305.       DText.IText[0]=(UBYTE) c;
  306.       PrintIText(ConPort,&DText,456L+8L*i,8L*line);
  307.       i++;
  308.       }
  309.     if(i>22)
  310.       {
  311.       co->par[i]=TASKNO;
  312.       break;
  313.       }
  314.     }
  315.   }
  316. input_star(line,pla)
  317. int line;
  318. int pla;
  319.   {
  320.   int sta;
  321.   DText.FrontPen=GREENPEN;
  322.   DText.IText=(UBYTE *) "STAR  >";
  323.   PrintIText(ConPort,&DText,400L,8L*line);
  324.   while( (sta=cget(pla)-'a') <0 || sta>=STARNO );
  325.   DText.IText=(UBYTE *)" ";
  326.   DText.IText[0]=(UBYTE) sta+'A';
  327.   PrintIText(ConPort,&DText,456L,8L*line);
  328.   return(sta);
  329.   }
  330. input_star_or_ret(line,pla)
  331. int line;
  332. int pla;
  333.   {
  334.   int sta;
  335.   DText.FrontPen=GREENPEN;
  336.   DText.IText=(UBYTE *) "STAR  >";
  337.   PrintIText(ConPort,&DText,400L,8L*line);
  338.   while( ((sta=cget(pla)-'a') <0 || sta>=STARNO) && sta!=0x0d-'a' );
  339.   if(sta==0x0d-'a') return(STARNO);
  340.   DText.IText=(UBYTE *)" ";
  341.   DText.IText[0]=(UBYTE) sta+'A';
  342.   PrintIText(ConPort,&DText,456L,8L*line);
  343.   return(sta);
  344.   }
  345. input_player_or_ret(line,pla)
  346. int line;
  347. int pla;
  348.   {
  349.   int c,d=PLAYERNO;
  350.   DText.FrontPen=GREENPEN;
  351.   DText.IText=(UBYTE *) "POWER >None";
  352.   PrintIText(ConPort,&DText,400L,8L*line);
  353.   while(1)
  354.     {
  355.     c=cget(pla);
  356.     if(c>='a' && (c-'a')<PLAYERNO)
  357.       {
  358.       d=c-'a';
  359.       c=0x0d;
  360.       }
  361.     if(c==',' && d>0)
  362.       {
  363.       d--;
  364.       }
  365.     if(c=='.' && d<PLAYERNO)
  366.       {
  367.       d++;
  368.       }
  369.     SetAPen(ConPort,BLACKPEN);
  370.     RectFill(ConPort,456L,line*8L,639L,line*8L+7L);
  371.     SetAPen(ConPort,GREENPEN);
  372.     if(d<PLAYERNO)
  373.       {
  374.       DText.FrontPen=PLAYERPEN(d);
  375.       DText.IText=(UBYTE *)general.pname[d];
  376.       PrintIText(ConPort,&DText,456L,8L*line);
  377.       }
  378.     else
  379.       {
  380.       DText.FrontPen=GREENPEN;
  381.       DText.IText=(UBYTE *)"None";
  382.       PrintIText(ConPort,&DText,456L,8L*line);
  383.       }
  384.     if(c==0x0d)
  385.       {
  386.       DText.FrontPen=GREENPEN;
  387.       return(d);
  388.       }
  389.     }
  390.   }
  391. input_planet(line,pla)
  392. int line;
  393. int pla;
  394.   {
  395.   int c;
  396.   DText.FrontPen=GREENPEN;
  397.   DText.IText=(UBYTE *) "PLANET>";
  398.   PrintIText(ConPort,&DText,400L,8L*line);
  399.   while((c=cget(pla))<'0' || c>'9');
  400.   DText.IText=(UBYTE *)" ";
  401.   DText.IText[0]=(UBYTE) c;
  402.   PrintIText(ConPort,&DText,456L,8L*line);
  403.   return(c-'0');
  404.   }
  405. input_planet_or_ret(line,pla)
  406. int line;
  407. int pla;
  408.   {
  409.   int c;
  410.   DText.FrontPen=GREENPEN;
  411.   DText.IText=(UBYTE *) "PLANET>";
  412.   PrintIText(ConPort,&DText,400L,8L*line);
  413.   while(((c=cget(pla))<'0' || c>'9') && c!=0x0d);
  414.   if(c==0x0d) return(PLANETNO);
  415.   DText.IText=(UBYTE *)" ";
  416.   DText.IText[0]=(UBYTE) c;
  417.   PrintIText(ConPort,&DText,456L,8L*line);
  418.   return(c-'0');
  419.   }
  420. input_ship_in_task(line,pla,tas)
  421. int line;
  422. int pla;
  423. int tas;
  424.   {
  425.   int c,d,e;
  426.   DText.FrontPen=GREENPEN;
  427.   for(d=0;d<SHIPNO;d++) if(INTASK(pla,tas,d)) break;
  428.   DText.IText=(UBYTE *) "SHIP  >";
  429.   PrintIText(ConPort,&DText,400L,8L*line);
  430.   if (d==SHIPNO) return(0);
  431.   DText.IText=(UBYTE *)ship[d].name;
  432.   PrintIText(ConPort,&DText,456L,8L*line);
  433.   while(1)
  434.     {
  435.     c=cget(pla);
  436.     if(c>='a' && (c-'a')<SHIPNO && INTASK(pla,tas,c-'a'))
  437.       {
  438.       d=c-'a';
  439.       c=0x0d;
  440.       }
  441.     if(c==',')
  442.       {
  443.       e=d-1;
  444.       for(;e>=0;e--) if(INTASK(pla,tas,e)) break;
  445.       if(e>=0) d=e;
  446.       }
  447.     if(c=='.')
  448.       {
  449.       e=d+1;
  450.       for(;e<SHIPNO;e++) if(INTASK(pla,tas,e)) break;
  451.       if(e<SHIPNO) d=e;
  452.       }
  453.     SetAPen(ConPort,BLACKPEN);
  454.     RectFill(ConPort,456L,line*8L,639L,line*8L+7L);
  455.     SetAPen(ConPort,GREENPEN);
  456.     DText.IText=(UBYTE *)ship[d].name;
  457.     PrintIText(ConPort,&DText,456L,8L*line);
  458.     if(c==0x0d) return(d);
  459.     }
  460.   }
  461. input_product(line,pla,tech)
  462. int line;
  463. int pla;
  464. int tech;
  465.   {
  466.   int c,d=RESEARCHING,e;
  467.   DText.FrontPen=GREENPEN;
  468.   DText.IText=(UBYTE *) "BUILD >";
  469.   PrintIText(ConPort,&DText,400L,8L*line);
  470.   DText.IText=(UBYTE *)"Researching";
  471.   PrintIText(ConPort,&DText,456L,8L*line);
  472.   while(1)
  473.     {
  474.     c=cget(pla);
  475.     if(c>='a' && (c-'a')<SHIPNO && ship[c-'a'].techlevel<=tech)
  476.       {
  477.       d=c-'a';
  478.       c=0x0d;
  479.       }
  480.     if(c=='M') {d=MINING;c=0x0d;}
  481.     if(c=='I') {d=INVESTING;c=0x0d;}
  482.     if(c=='R') {d=RESEARCHING;c=0x0d;}
  483.     if(c==',')
  484.       {
  485.       e=d-1;
  486.       if(e<SHIPNO)
  487.         {
  488.         for(;e>=0;e--) if(ship[e].techlevel<=tech&&!(ship[e].special&NOTPROD)) break;
  489.         if(e>=0) d=e;
  490.         }
  491.       else d=e;
  492.       }
  493.     if(c=='.')
  494.       {
  495.       e=d+1;
  496.       if(e>=SHIPNO)
  497.         {
  498.         if(e<DO_NOTHING) d=e;
  499.         }
  500.       else
  501.         {
  502.         for(;e<SHIPNO;e++) if(ship[e].techlevel<=tech&&!(ship[e].special&NOTPROD)) break;
  503.         d=e;
  504.         }
  505.       }
  506.     SetAPen(ConPort,BLACKPEN);
  507.     RectFill(ConPort,456L,line*8L,639L,line*8L+7L);
  508.     SetAPen(ConPort,GREENPEN);
  509.     if(d<SHIPNO && !(ship[d].special&NOTPROD)) DText.IText=(UBYTE *)ship[d].name;
  510.     if(d==RESEARCHING) DText.IText=(UBYTE *)"Researching";
  511.     if(d==MINING) DText.IText=(UBYTE *)"Mining";
  512.     if(d==INVESTING) DText.IText=(UBYTE *)"Investing";
  513.     PrintIText(ConPort,&DText,456L,8L*line);
  514.     if(c==0x0d) return(d);
  515.     }
  516.   }
  517. input_ship(line,pla)
  518. int line;
  519. int pla;
  520.   {
  521.   int c,d=SHIPNO-1,e;
  522.   DText.FrontPen=GREENPEN;
  523.   DText.IText=(UBYTE *) "SHIP  >";
  524.   PrintIText(ConPort,&DText,400L,8L*line);
  525.   DText.IText=(UBYTE *)ship[d].name;
  526.   PrintIText(ConPort,&DText,456L,8L*line);
  527.   while(1)
  528.     {
  529.     c=cget(pla);
  530.     if(c>='a' && (c-'a')<SHIPNO)
  531.       {
  532.       d=c-'a';
  533.       c=0x0d;
  534.       }
  535.     if(c==',')
  536.       {
  537.       for(e=d-1;e>=0;e--) if(ship[e].name[0]!='\0') break;
  538.       if(e>=0) d=e;
  539.       }
  540.     if(c=='.')
  541.       {
  542.       for(e=d+1;e<SHIPNO;e++) if(ship[e].name[0]!='\0')break;
  543.       if(e<SHIPNO) d=e;
  544.       }
  545.     SetAPen(ConPort,BLACKPEN);
  546.     RectFill(ConPort,456L,line*8L,639L,line*8L+7L);
  547.     SetAPen(ConPort,GREENPEN);
  548.     DText.IText=(UBYTE *)ship[d].name;
  549.     PrintIText(ConPort,&DText,456L,8L*line);
  550.     if(c==0x0d) return(d);
  551.     }
  552.   }
  553. input_status(line,pla,status)
  554. int line;
  555. int pla;
  556. int status;
  557.   {
  558.   int c;
  559.   DText.FrontPen=GREENPEN;
  560.   DText.IText=(UBYTE *) "STATUS>";
  561.   PrintIText(ConPort,&DText,400L,8L*line);
  562.   DText.IText=(UBYTE *) "        ";
  563.   pstr(status,DText.IText);
  564.   PrintIText(ConPort,&DText,456L,8L*line);
  565.   while(1)
  566.     {
  567.     c=cget(pla);
  568.     if(c==',' && status>RELMIN) status--;
  569.     if(c=='.' && status<RELMAX) status++;
  570.     if(c=='w') {status=WAR;c=0x0d;}
  571.     if(c=='p') {status=PEACE;c=0x0d;}
  572.     if(c=='a') {status=ALLIANCE;c=0x0d;}
  573.     pstr(status,DText.IText);
  574.     PrintIText(ConPort,&DText,456L,8L*line);
  575.     if(c==0x0d) return(status);
  576.     }
  577.   }
  578. input_number(line,pla,max)
  579. int line;
  580. int pla;
  581. int max;
  582.   {
  583.   int pos,c,d=0;
  584.   DText.FrontPen=GREENPEN;
  585.   DText.IText=(UBYTE *)"NUMBER>000(000)";
  586.   mstr(max,DText.IText+11);
  587.   PrintIText(ConPort,&DText,400L,line*8L);
  588.   if(max<=0) return(0);
  589.   DText.IText=(UBYTE *)"000";
  590.   while(1)
  591.     {
  592.     c=coget();
  593.     if(c=='.' && d<max) d++;
  594.     if(c==',' && d>0) d--;
  595.     if(c>='0' && c<='9' && (c-'a')<=max)
  596.       {
  597.       d=c-'0';
  598.       c=0x0d;
  599.       }
  600.     if(c=='>') d=max;
  601.     if(c=='<') d=0;
  602.     mstr(d,DText.IText);
  603.     PrintIText(ConPort,&DText,456L,line*8L);
  604.     if(c==0x0d) return(d);
  605.     }
  606.   }
  607. input_player(line,pla)
  608. int line;
  609. int pla;
  610.   {
  611.   int c,d=0;
  612.   DText.FrontPen=GREENPEN;
  613.   if (pla==0) d++;
  614.   DText.IText=(UBYTE *) "POWER >";
  615.   PrintIText(ConPort,&DText,400L,8L*line);
  616.   DText.FrontPen=PLAYERPEN(d);
  617.   DText.IText=(UBYTE *)general.pname[d];
  618.   PrintIText(ConPort,&DText,456L,8L*line);
  619.   while(1)
  620.     {
  621.     c=cget(pla);
  622.     if(c>='a' && (c-'a')<PLAYERNO && (c-'a')!=pla)
  623.       {
  624.       d=c-'a';
  625.       c=0x0d;
  626.       }
  627.     if(c==',' && d>0)
  628.       {
  629.       d--;
  630.       if(d==pla)
  631.         {
  632.         if(d==0) d=1;
  633.         else d--;
  634.         }
  635.       }
  636.     if(c=='.' && d+1<PLAYERNO)
  637.       {
  638.       d++;
  639.       if(d==pla)
  640.         {
  641.         if(d==PLAYERNO-1) d--;
  642.         else d++;
  643.         }
  644.       }
  645.     SetAPen(ConPort,BLACKPEN);
  646.     RectFill(ConPort,456L,line*8L,639L,line*8L+7L);
  647.     SetAPen(ConPort,GREENPEN);
  648.     DText.FrontPen=PLAYERPEN(d);
  649.     DText.IText=(UBYTE *)general.pname[d];
  650.     PrintIText(ConPort,&DText,456L,8L*line);
  651.     if(c==0x0d)
  652.       {
  653.       DText.FrontPen=GREENPEN;
  654.       return(d);
  655.       }
  656.     }
  657.   }
  658. input_player_pref(line,pla)
  659. int line;
  660. int pla;
  661.   {
  662.   int c,d;
  663.   DText.FrontPen=GREENPEN;
  664.   d=pla;
  665.   DText.IText=(UBYTE *) "POWER >";
  666.   PrintIText(ConPort,&DText,400L,8L*line);
  667.   DText.FrontPen=PLAYERPEN(d);
  668.   DText.IText=(UBYTE *)general.pname[d];
  669.   PrintIText(ConPort,&DText,456L,8L*line);
  670.   while(1)
  671.     {
  672.     c=cget(pla);
  673.     if(c>='a' && (c-'a')<PLAYERNO)
  674.       {
  675.       d=c-'a';
  676.       c=0x0d;
  677.       }
  678.     if(c==',' && d>0)
  679.       {
  680.       d--;
  681.       }
  682.     if(c=='.' && d+1<PLAYERNO)
  683.       {
  684.       d++;
  685.       }
  686.     SetAPen(ConPort,BLACKPEN);
  687.     RectFill(ConPort,456L,line*8L,639L,line*8L+7L);
  688.     SetAPen(ConPort,GREENPEN);
  689.     DText.FrontPen=PLAYERPEN(d);
  690.     DText.IText=(UBYTE *)general.pname[d];
  691.     PrintIText(ConPort,&DText,456L,8L*line);
  692.     if(c==0x0d)
  693.       {
  694.       DText.FrontPen=GREENPEN;
  695.       return(d);
  696.       }
  697.     }
  698.   }
  699. cprint(pla,str1,str2,str3,str4,str5)
  700. int pla;
  701. char *str1;
  702. char *str2;
  703. char *str3;
  704. char *str4;
  705. char *str5;
  706.   {
  707.   if(!display_check(pla)) return();
  708.   SetAPen(ConPort,BLACKPEN);
  709.   RectFill(ConPort,400L,0L,639L,39L);
  710.   DText.FrontPen=GREENPEN;
  711.   DText.IText=(UBYTE *) str1;
  712.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,0L);
  713.   DText.IText=(UBYTE *) str2;
  714.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,8L);
  715.   DText.IText=(UBYTE *) str3;
  716.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,16L);
  717.   DText.IText=(UBYTE *) str4;
  718.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,24L);
  719.   DText.IText=(UBYTE *) str5;
  720.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,32L);
  721.   }
  722. nprint(pla,str)
  723. int pla;
  724. char *str;
  725.   {
  726.   int i;
  727.   if(!display_check(pla)) return();
  728.   DText.FrontPen=GREENPEN;
  729.   DText.IText=(UBYTE *)"                              ";
  730.   for(i=0;str[i]!='\0';i++) DText.IText[i]=(UBYTE) str[i];
  731.   for(;i<30;i++) DText.IText[i]=(UBYTE) ' ';
  732.   PrintIText(ConPort,&DText,400L,32L);
  733.   }
  734. randomize()
  735.   {
  736.   ULONG Seconds,Micros;
  737.   CurrentTime(&Seconds,&Micros);
  738.   srand((int)(Seconds+Micros));
  739.   }
  740. cget(pla)
  741. int pla;
  742.   {
  743.   long Code,Class,X,Y;
  744.   while(1)
  745.     {
  746.     WaitPort(ConWindow->UserPort);
  747.     mes=(struct IntuiMessage *) GetMsg(ConWindow->UserPort);
  748.     Class=mes->Class;
  749.     Code=mes->Code;
  750.     X=mes->MouseX;
  751.     Y=mes->MouseY;
  752.     ReplyMsg(mes);
  753.     if(Class==VANILLAKEY) return(Code);
  754.     if(Class==MOUSEBUTTONS && Code==SELECTDOWN) process_mouse(pla,(int) X/8,(int) Y/8);
  755.     if(Class==MOUSEBUTTONS && Code==MENUDOWN) showstatus(pla);
  756.     }
  757.   }
  758. coget()
  759.   {
  760.   long Code,Class;
  761.   while(1)
  762.     {
  763.     WaitPort(ConWindow->UserPort);
  764.     mes=(struct IntuiMessage *) GetMsg(ConWindow->UserPort);
  765.     Class=mes->Class;
  766.     Code=mes->Code;
  767.     ReplyMsg(mes);
  768.     if(Class==VANILLAKEY) return(Code);
  769.     }
  770.   }
  771. wait_space(pla)
  772.   {
  773.   if(!display_check(pla)) return();
  774.   DText.FrontPen=GREENPEN;
  775.   DText.IText=(UBYTE *) "    PRESS SPACE TO CONTINUE   ";
  776.   DText.DrawMode=JAM2 | INVERSVID;
  777.   PrintIText(ConPort,&DText,400L,32L);
  778.   while(coget()!=' ');
  779.   DText.DrawMode=JAM2;
  780.   DText.IText=(UBYTE *) "                              ";
  781.   PrintIText(ConPort,&DText,400L,32L);
  782.   }
  783. cinput(str,line)
  784. char *str;
  785. int line;
  786.   {
  787.   int pos,c;
  788.   DText.FrontPen=GREENPEN;
  789.   DText.IText=(UBYTE *)">                             ";
  790.   PrintIText(ConPort,&DText,400L,line*8L);
  791.   pos=0;
  792.   *str='\0';
  793.   while(pos<STRLENGTH-1)
  794.     {
  795.     SetAPen(ConPort,GREENPEN);
  796.     RectFill(ConPort,408L+pos*8,line*8L,415L+pos*8,line*8L+7);
  797.     c=coget();
  798.     SetAPen(ConPort,BLACKPEN);
  799.     RectFill(ConPort,408L+pos*8,line*8L,415L+pos*8,line*8L+7);
  800.     switch(c)
  801.       {
  802.       case '\b':if (pos) pos--;
  803.                 str[pos]='\0';
  804.                 DText.IText=(UBYTE *)" ";
  805.                 PrintIText(ConPort,&DText,408L+pos*8,line*8L);
  806.                 break;
  807.       case 0x0d:pos=STRLENGTH-1;break;
  808.       default  :str[pos]=c;
  809.                 pos++;
  810.                 str[pos]='\0';
  811.                 DText.IText=(UBYTE *)str;
  812.                 PrintIText(ConPort,&DText,408L,line*8L);
  813.       }
  814.     }
  815.   }
  816. mapdisplay(pla)
  817. int pla;
  818.   {
  819.   int sta,tas,i,j,c;
  820.   if(!display_check(pla)) return();
  821.   for(sta=0;sta<STARNO;sta++)
  822.     {
  823.     DText.IText=(UBYTE *)" ";
  824.     DText.IText[0]=(UBYTE) ('A'+sta);
  825.     c=CommData[pla].star[sta].ruler;
  826.     if(c<PLAYERNO) DText.FrontPen=PLAYERPEN(c);
  827.     if(c==FIGHTING) DText.FrontPen=OTHERPEN;
  828.     if(c==UNINHABITED || CommData[pla].star[sta].when<0) DText.FrontPen=WHITEPEN;
  829.     if(!knowstar(pla,sta) && CommData[pla].star[sta].when>=0) DText.DrawMode |= INVERSVID;
  830.                                                          else DText.DrawMode &=~INVERSVID;
  831.     PrintIText(ConPort,&DText,16L*star[sta].x,8L*star[sta].y);
  832.     DText.IText=(UBYTE *)" ";
  833.     DText.DrawMode=JAM2;
  834.     PrintIText(ConPort,&DText,16L*star[sta].x+8L,8L*star[sta].y);
  835.     if(!knowstar(pla,sta)) continue;
  836.     DText.IText=(UBYTE *)" ";
  837.     DText.DrawMode=JAM1;
  838.     for(i=0;i<PLAYERNO;i++)
  839.       {
  840.       DText.FrontPen=PLAYERPEN(i);
  841.       for(j=0;j<TASKNO;j++)
  842.         {
  843.         DText.IText[0]=(UBYTE) TASKCHAR(j);
  844.         if(task[i][j].headed==sta && task[i][j].arriving<=general.time)
  845.           PrintIText(ConPort,&DText,16L*star[sta].x+8L,8L*star[sta].y);
  846.         }
  847.       }
  848.     DText.DrawMode=JAM2;
  849.     }
  850.   DText.FrontPen=GREENPEN;
  851.   }
  852. starsummary(pla,sta)
  853. int pla;
  854. int sta;
  855.   {
  856.   int p,pla2,tas,sta2;
  857.   if(!display_check(pla)) return;
  858.   screen1=STARSUMMARY;show1=sta;
  859.   SetAPen(ConPort,BLACKPEN);
  860.   RectFill(ConPort,400L,40L,639L,119L);
  861.   if(sta<0 || sta>=STARNO) return();
  862.   if(sta!=sortsta) sortstars(sta);
  863.   pla2=CommData[pla].star[sta].ruler;
  864.   if(pla2<PLAYERNO)  DText.FrontPen=PLAYERPEN(pla2);
  865.   if(pla2==FIGHTING) DText.FrontPen=OTHERPEN;
  866.   if(CommData[pla].star[sta].when<0 ||pla2==UNINHABITED) DText.FrontPen=WHITEPEN;
  867.   DText.IText=(UBYTE *)"Star %(%%,%%)                 ";
  868.   *(DText.IText+5)=(UBYTE)'A'+sta;
  869.   rstr(star[sta].x,DText.IText+7);
  870.   rstr(star[sta].y,DText.IText+10);
  871.   DText.DrawMode |= INVERSVID;
  872.   PrintIText(ConPort,&DText,400L,40L);
  873.   DText.DrawMode &=~INVERSVID;
  874.   if(knowstar(pla,sta))
  875.     for(p=0;p<PLANETNO;p++)
  876.       {
  877.       if(star[sta].planet[p].size==0) continue;
  878.       if(star[sta].planet[p].mineable) DText.DrawMode=JAM2|INVERSVID;
  879.       if(star[sta].planet[p].ruler!=PLAYERNO) DText.FrontPen=PLAYERPEN(star[sta].planet[p].ruler);
  880.         else DText.FrontPen=WHITEPEN;
  881.       DText.IText=(UBYTE *)"%:%%%/%%%/%%%  ";
  882.       *(DText.IText+ 0)=(UBYTE)'0'+p;
  883.       mstr(star[sta].planet[p].size,DText.IText+2);
  884.       mstr(star[sta].planet[p].industry,DText.IText+10);
  885.       *(DText.IText+13)=(UBYTE)' ';
  886.       if(star[sta].planet[p].population*star[sta].planet[p].industry)
  887.         {
  888.         *(DText.IText+13)=(UBYTE) 'a'+star[sta].planet[p].producing;
  889.         if(star[sta].planet[p].producing==RESEARCHING)
  890.           *(DText.IText+13)=(UBYTE) 'R';
  891.         if(star[sta].planet[p].producing==INVESTING)
  892.           *(DText.IText+13)=(UBYTE) 'I';
  893.         if(star[sta].planet[p].producing==MINING)
  894.           *(DText.IText+13)=(UBYTE) 'M';
  895.         if(star[sta].planet[p].producing==DO_NOTHING)
  896.           *(DText.IText+13)=(UBYTE) ' ';
  897.         }
  898.       PrintIText(ConPort,&DText,400L+120*(p%2),48L+8*((int)p/2));
  899.       if(star[sta].planet[p].poptype!=PLAYERNO) DText.FrontPen=PLAYERPEN(star[sta].planet[p].poptype);
  900.         else DText.FrontPen=WHITEPEN;
  901.       DText.IText=(UBYTE *)"   ";
  902.       mstr(star[sta].planet[p].population,DText.IText);
  903.       PrintIText(ConPort,&DText,448L+120*(p%2),48L+8*((int)p/2));
  904.       DText.DrawMode=JAM2;
  905.       }
  906.   for(pla2=0;pla2<PLAYERNO;pla2 ++)
  907.     {
  908.     DText.DrawMode&=~INVERSVID;
  909.     DText.IText=(UBYTE *)"Tf";
  910.     DText.FrontPen=PLAYERPEN(pla2);
  911.     PrintIText(ConPort,&DText,400L,80L+8*pla2);
  912.     DText.IText=(UBYTE *) " ";
  913.     for(tas=0;tas<TASKNO;tas++) if(task[pla2][tas].headed==sta)
  914.       {
  915.       *DText.IText=(UBYTE)TASKCHAR(tas);
  916.       if(task[pla2][tas].arriving>general.time) DText.DrawMode|= INVERSVID;
  917.                                           else DText.DrawMode&=~INVERSVID;
  918.       if((task[pla2][tas].arriving>general.time || !knowstar(pla,sta)) && pla2!=pla && pla!=mode)
  919.         continue;
  920.       PrintIText(ConPort,&DText,424L+tas*8,80L+8*pla2);
  921.       }
  922.     }
  923.   DText.IText=(UBYTE *) "%  ";
  924.   if(pla!=PLAYERNO) for(sta2=1;sta2<8;sta2++)
  925.     {
  926.     DText.IText[0]=(UBYTE) 'A'+sort[sta2];
  927.     tstr(dis[sta2],DText.IText+1);
  928.     pla2=CommData[pla].star[sort[sta2]].ruler;
  929.     if(pla2<PLAYERNO)  DText.FrontPen=PLAYERPEN(pla2);
  930.     if(pla2==FIGHTING) DText.FrontPen=OTHERPEN;
  931.     if(CommData[pla].star[sort[sta2]].when<0 ||pla2==UNINHABITED) DText.FrontPen=WHITEPEN;
  932.     if(!knowstar(pla,sort[sta2]) && CommData[pla].star[sort[sta2]].when>=0) DText.DrawMode|=INVERSVID;
  933.                       else DText.DrawMode&=~INVERSVID;
  934.     PrintIText(ConPort,&DText,368L+sta2*32L,112L);
  935.     }
  936.   DText.FrontPen=GREENPEN;
  937.   DText.DrawMode=JAM2;
  938.   }
  939. tasksummary(pla1,pla,tas)
  940. int pla1;
  941. int pla;
  942. int tas;
  943.   {
  944.   int i,shi,line;
  945.   if(!display_check(pla1)) return();
  946.   SetAPen(ConPort,BLACKPEN);
  947.   RectFill(ConPort,400L,120L,639L,199L);
  948.   if(task[pla][tas].headed==-1) return();
  949.   if(task[pla][tas].arriving>general.time||!knowstar(pla1,task[pla][tas].headed))
  950.     if(pla1!=pla && pla1!=mode) return();
  951.   screen2=TASKSUMMARY;showpla2=pla;show2=tas;
  952.   DText.FrontPen=PLAYERPEN(pla);
  953.   if(task[pla][tas].arriving<=general.time)
  954.     {
  955.     DText.IText=(UBYTE *)"Tf % at %    L:%%% S:%%% R:%%%";
  956.     }
  957.   else
  958.     {
  959.     DText.IText=(UBYTE *)"Tf % vs %/%% L:%%% S:%%% R:%%%";
  960.     *(DText.IText+10)=(UBYTE)'0'+((task[pla][tas].arriving-general.time)/10);
  961.     *(DText.IText+11)=(UBYTE)'0'+((task[pla][tas].arriving-general.time)%10);
  962.     }
  963.   if(tas<TASKNO) *(DText.IText+ 3)=(UBYTE) TASKCHAR(tas);
  964.     else *(DText.IText+ 3)=(UBYTE) '*';
  965.   *(DText.IText+ 8)=(UBYTE) 'A'+task[pla][tas].headed;
  966.   if (pla1!=mode && pla1!=pla) mstr(task_free(pla,tas),DText.IText+15);
  967.     else mstr(task_visi(pla,tas),DText.IText+15);
  968.   mstr(task_speed(pla,tas),DText.IText+21);
  969.   mstr(task_range(pla,tas),DText.IText+27);
  970.   DText.DrawMode |= INVERSVID;
  971.   PrintIText(ConPort,&DText,400L,120L);
  972.   DText.DrawMode &=~INVERSVID;
  973.   DText.FrontPen=WHITEPEN;
  974.   line=1;
  975.   for(shi=0;shi<SHIPNO;shi ++)
  976.     {
  977.     if(!task[pla][tas].ship_free[shi] && !task[pla][tas].ship_load[shi]) continue;
  978.     if(pla1!=mode && pla1!=pla && !task[pla][tas].ship_free[shi]) continue;
  979.     if(line==10)
  980.       {
  981.       wait_space(pla1);
  982.       DText.FrontPen=WHITEPEN;
  983.       SetAPen(ConPort,BLACKPEN);
  984.       RectFill(ConPort,400L,128L,639L,199L);
  985.       line=1;
  986.       }
  987.     DText.IText=(UBYTE *)ship[shi].name;
  988.     PrintIText(ConPort,&DText,400L,120L+line*8);
  989.     if(pla1==pla || pla1==mode)
  990.       {
  991.       DText.IText=(UBYTE *)"   /   ";
  992.       mstr(task[pla][tas].ship_free[shi],DText.IText);
  993.       mstr(task[pla][tas].ship_load[shi],DText.IText+4);
  994.       PrintIText(ConPort,&DText,584L,120L+line*8);
  995.       }
  996.     else
  997.       {
  998.       DText.IText=(UBYTE *)"   ";
  999.       mstr(task[pla][tas].ship_free[shi],DText.IText);
  1000.       PrintIText(ConPort,&DText,616L,120L+line*8);
  1001.       }
  1002.     line++;
  1003.     }
  1004.   DText.FrontPen=GREENPEN;
  1005.   }
  1006. shipsummary(pla,shi)
  1007. int pla;
  1008. int shi;
  1009.   {
  1010.   if(!display_check(pla)) return();
  1011.   screen2=SHIPSUMMARY;showpla2=pla;show2=shi;
  1012.   SetAPen(ConPort,BLACKPEN);
  1013.   RectFill(ConPort,400L,120L,639L,199L);
  1014.   DText.FrontPen=WHITEPEN;
  1015.   DText.DrawMode |= INVERSVID;
  1016.   DText.IText=(UBYTE *)"                              ";
  1017.   PrintIText(ConPort,&DText,400L,120L);
  1018.   DText.IText=(UBYTE *)ship[shi].name;
  1019.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,120L);
  1020.   DText.DrawMode &=~INVERSVID;
  1021.   DText.IText=(UBYTE *)"Size      :000 Capacity  :000";
  1022.   mstr(ship[shi].size,DText.IText+11);
  1023.   mstr(ship[shi].capacity,DText.IText+26);
  1024.   PrintIText(ConPort,&DText,400L,128L);
  1025.   DText.IText=(UBYTE *)"HyperSpeed:000 HyperRange:000";
  1026.   mstr(ship[shi].hypspeed,DText.IText+11);
  1027.   mstr(ship[shi].hyprange,DText.IText+26);
  1028.   PrintIText(ConPort,&DText,400L,136L);
  1029.   DText.IText=(UBYTE *)"Attack    :000 No of At. :000";
  1030.   mstr(ship[shi].attack,DText.IText+11);
  1031.   mstr(ship[shi].attackno,DText.IText+26);
  1032.   PrintIText(ConPort,&DText,400L,144L);
  1033.   DText.IText=(UBYTE *)"Speed     :000 Shields   :000";
  1034.   mstr(ship[shi].speed,DText.IText+11);
  1035.   mstr(ship[shi].shields,DText.IText+26);
  1036.   PrintIText(ConPort,&DText,400L,152L);
  1037.   if(!(ship[shi].special&NOTPROD))
  1038.     {
  1039.     if(ship[shi].techlevel>general.techlevel[pla]) DText.DrawMode |= INVERSVID;
  1040.     DText.IText=(UBYTE *)"Techcost  :000 Techlevel :000";
  1041.     PrintIText(ConPort,&DText,400L,160L);
  1042.     DText.IText=(UBYTE *)"   ";
  1043.     mstr(ship[shi].techcost,DText.IText);
  1044.     PrintIText(ConPort,&DText,488L,160L);
  1045.     mstr(ship[shi].techlevel,DText.IText);
  1046.     PrintIText(ConPort,&DText,608L,160L);
  1047.     DText.DrawMode &=~INVERSVID;
  1048.     }
  1049.   DText.IText =(UBYTE *)"Starkill ";
  1050.   if(ship[shi].special&STARKILLER) PrintIText(ConPort,&DText,400L,168L);
  1051.   DText.IText =(UBYTE *)"One-Shot ";
  1052.   if(ship[shi].special&KAMIKAZE) PrintIText(ConPort,&DText,480L,168L);
  1053.   DText.IText =(UBYTE *)"Invisible";
  1054.   if(ship[shi].special&INVISIBLE) PrintIText(ConPort,&DText,560L,168L);
  1055.   DText.IText =(UBYTE *)"CataStart";
  1056.   if(ship[shi].special&FASTEJECTABLE) PrintIText(ConPort,&DText,400L,176L);
  1057.   DText.IText =(UBYTE *)"Not build";
  1058.   if(ship[shi].special&NOTPROD) PrintIText(ConPort,&DText,480L,176L);
  1059.   DText.IText =(UBYTE *)"Theft    ";
  1060.   if(ship[shi].special&STEAL) PrintIText(ConPort,&DText,560L,176L);
  1061.   DText.IText =(UBYTE *)"Catapult ";
  1062.   if(ship[shi].special&FASTEJECTER) PrintIText(ConPort,&DText,400L,184L);
  1063.   DText.IText =(UBYTE *)"         ";
  1064.   if(ship[shi].special&NULL) PrintIText(ConPort,&DText,480L,184L);
  1065.   DText.IText =(UBYTE *)"         ";
  1066.   if(ship[shi].special&NULL) PrintIText(ConPort,&DText,560L,184L);
  1067.   DText.IText =(UBYTE *)"         ";
  1068.   if(ship[shi].special&NULL) PrintIText(ConPort,&DText,400L,192L);
  1069.   DText.IText =(UBYTE *)"         ";
  1070.   if(ship[shi].special&NULL) PrintIText(ConPort,&DText,480L,192L);
  1071.   DText.IText =(UBYTE *)"         ";
  1072.   if(ship[shi].special&NULL) PrintIText(ConPort,&DText,560L,192L);
  1073.   DText.FrontPen=GREENPEN;
  1074.   }
  1075. showstatus(pla)
  1076. int pla;
  1077.   {
  1078.   int i,s,p;
  1079.   if(!display_check(pla)) return();
  1080.   screen1=PLAYERSUMMARY;showpla1=pla;
  1081.   SetAPen(ConPort,BLACKPEN);
  1082.   RectFill(ConPort,400L,40L,639L,119L);
  1083.   DText.FrontPen=PLAYERPEN(pla);
  1084.   DText.DrawMode |= INVERSVID;
  1085.   DText.IText=(UBYTE *)"                              ";
  1086.   PrintIText(ConPort,&DText,400L,40L);
  1087.   DText.IText=(UBYTE *)"Year %%%%";
  1088.   qstr(general.time,DText.IText+5);
  1089.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,40L);
  1090.   DText.DrawMode &=~INVERSVID;
  1091.   DText.IText=(UBYTE *) general.pname[pla];
  1092.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,48L);
  1093.   DText.IText=(UBYTE *)"Pop:0000 Ind:0000 Tec:0000";
  1094.   qstr(population_no(pla),DText.IText+4);
  1095.   qstr(industry_no(pla),DText.IText+13);
  1096.   qstr(general.techlevel[pla],DText.IText+22);
  1097.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,56L);
  1098.   for(i=0;i<PLAYERNO;i++)
  1099.     {
  1100.     if (i==pla) continue;
  1101.     DText.FrontPen=PLAYERPEN(i);
  1102.     DText.IText=(UBYTE *) general.pname[i];
  1103.     PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,48L+(i+(i<pla))*16);
  1104.     if (!exists(i))
  1105.       {
  1106.       DText.IText=(UBYTE *)"Killed";
  1107.       PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,(i+(i<pla))*16+56L);
  1108.       continue;
  1109.       }
  1110.     DText.IText=(UBYTE *)"--------/--------";
  1111.     pstr(general.relation[pla][i],DText.IText);
  1112.     pstr(general.relation[i][pla],DText.IText+9);
  1113.     PrintIText(ConPort,&DText,452L,(i+(i<pla))*16+56L);
  1114.     DText.IText=(UBYTE *)"%:0000";
  1115.     if (pla==mode)
  1116.       {
  1117.       *DText.IText=(UBYTE)'T';
  1118.       qstr(general.techlevel[i],DText.IText+2);
  1119.       PrintIText(ConPort,&DText,592L,(i+(i<pla))*16+56L);
  1120.       *DText.IText=(UBYTE)'P';
  1121.       qstr(population_no(i),DText.IText+2);
  1122.       PrintIText(ConPort,&DText,400L,(i+(i<pla))*16+48L);
  1123.       *DText.IText=(UBYTE)'I';
  1124.       qstr(industry_no(i),DText.IText+2);
  1125.       PrintIText(ConPort,&DText,592L,(i+(i<pla))*16+48L);
  1126.       }
  1127.     }
  1128.   DText.FrontPen=GREENPEN;
  1129.   }
  1130. mstr(no,str)
  1131. int no;
  1132. char *str;
  1133.   {
  1134.   if(no<0) return();
  1135.   if(no<1000)
  1136.     {
  1137.     str[0]='0'+(no/100)%10;
  1138.     str[1]='0'+(no/10)%10;
  1139.     str[2]='0'+no%10;
  1140.     return();
  1141.     }
  1142.   str[0]=' ';
  1143.   str[1]='o';
  1144.   str[2]='o';
  1145.   return();
  1146.   }
  1147. rstr(no,str)
  1148. int no;
  1149. char *str;
  1150.   {
  1151.   if(no<0) return;
  1152.   if(no<100)
  1153.     {
  1154.     str[0]='0'+(no/10)%10;
  1155.     str[1]='0'+no%10;
  1156.     return();
  1157.     }
  1158.   str[0]='o';
  1159.   str[1]='o';
  1160.   return();
  1161.   }
  1162. tstr(no,str)
  1163. int no;
  1164. char *str;
  1165.   {
  1166.   if(no<0) return();
  1167.   if(no<10)
  1168.     {
  1169.     str[0]='0'+no;
  1170.     str[1]=' ';
  1171.     return();
  1172.     }
  1173.   if(no<100)
  1174.     {
  1175.     str[0]='0'+(no/10)%10;
  1176.     str[1]='0'+no%10;
  1177.     return();
  1178.     }
  1179.   str[0]='o';
  1180.   str[1]='o';
  1181.   }
  1182. qstr(no,str)
  1183. int no;
  1184. char *str;
  1185.   {
  1186.   if(no<0) return;
  1187.   if(no<10000)
  1188.     {
  1189.     str[0]='0'+(no/1000)%10;
  1190.     str[1]='0'+(no/100)%10;
  1191.     str[2]='0'+(no/10)%10;
  1192.     str[3]='0'+no%10;
  1193.     return();
  1194.     }
  1195.   str[0]=' ';
  1196.   str[1]=' ';
  1197.   str[2]='o';
  1198.   str[3]='o';
  1199.   return();
  1200.   }
  1201. pstr(rel,str)
  1202. int rel;
  1203. char *str;
  1204.   {
  1205.   if(rel==WAR)
  1206.     {
  1207.     str[0]='W';
  1208.     str[1]='a';
  1209.     str[2]='r';
  1210.     str[3]=' ';
  1211.     str[4]=' ';
  1212.     str[5]=' ';
  1213.     str[6]=' ';
  1214.     str[7]=' ';
  1215.     return();
  1216.     }
  1217.   if(rel==PEACE)
  1218.     {
  1219.     str[0]='P';
  1220.     str[1]='e';
  1221.     str[2]='a';
  1222.     str[3]='c';
  1223.     str[4]='e';
  1224.     str[5]=' ';
  1225.     str[6]=' ';
  1226.     str[7]=' ';
  1227.     return();
  1228.     }
  1229.   if(rel==ALLIANCE)
  1230.     {
  1231.     str[0]='A';
  1232.     str[1]='l';
  1233.     str[2]='l';
  1234.     str[3]='i';
  1235.     str[4]='a';
  1236.     str[5]='n';
  1237.     str[6]='c';
  1238.     str[7]='e';
  1239.     return();
  1240.     }
  1241.   }
  1242. clearall(pla)
  1243. int pla;
  1244.   {
  1245.   register long i,j;
  1246.   if(!display_check(pla)) return();
  1247.   fline=0;
  1248.   SetRast(ConPort,BLACKPEN);
  1249.   SetAPen(ConPort,WHITEPEN);
  1250.   for(i=4;i<XMAX*16+4;i += 16)
  1251.     for(j=4;j<YMAX*8+4;j += 8)
  1252.       WritePixel(ConPort,i,j);
  1253.   screen1=CLEAR;
  1254.   screen2=CLEAR;
  1255.   }
  1256. showtasks(pla1,pla)
  1257. int pla1;
  1258. int pla;
  1259.   {
  1260.   int i;
  1261.   if(!display_check(pla1)) return();
  1262.   screen2=TASKOVERVIEW;showpla2=pla;
  1263.   SetAPen(ConPort,BLACKPEN);
  1264.   RectFill(ConPort,400L,120L,639L,199L);
  1265.   SetAPen(ConPort,PLAYERPEN(pla));
  1266.   RectFill(ConPort,400L,120L,639L,127L);
  1267.   DText.FrontPen=PLAYERPEN(pla);
  1268.   DText.DrawMode |= INVERSVID;
  1269.   DText.IText=(UBYTE *)"Taskforceoverview";
  1270.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,120L);
  1271.   DText.DrawMode &=~INVERSVID;
  1272.   DText.FrontPen=WHITEPEN;
  1273.   DText.IText=(UBYTE *)"Tf % %/%%";
  1274.   for(i=0;i<TASKNO;i++)
  1275.     {
  1276.     if(task[pla][i].headed==-1) continue;
  1277.     if(pla1!=pla && mode!=pla1 && (!knowstar(pla1,task[pla][i].headed) || task[pla][i].arriving>general.time) ) continue;
  1278.     DText.IText[3]=(UBYTE) TASKCHAR(i);
  1279.     DText.IText[5]=(UBYTE) 'A'+task[pla][i].headed;
  1280.     if(task[pla][i].arriving<=general.time)
  1281.       {
  1282.       DText.DrawMode&=~INVERSVID;
  1283.       DText.IText[6]=(UBYTE)' ';
  1284.       DText.IText[7]=(UBYTE)' ';
  1285.       DText.IText[8]=(UBYTE)' ';
  1286.       }
  1287.     else
  1288.       {
  1289.       DText.DrawMode|= INVERSVID;
  1290.       DText.IText[6]=(UBYTE)'/';
  1291.       rstr(task[pla][i].arriving-general.time,DText.IText+7);
  1292.       }
  1293.     PrintIText(ConPort,&DText,400L+80*(i/9),8*(i%9)+128L);
  1294.     }
  1295.   DText.DrawMode=JAM2;
  1296.   DText.FrontPen=GREENPEN;
  1297.   }
  1298. output_fight(pla,pla1,shi1,pla2,shi2,str)
  1299. int pla;
  1300. int pla1;
  1301. int shi1;
  1302. int pla2;
  1303. int shi2;
  1304. char *str;
  1305.   {
  1306.   long pos;
  1307.   if(!display_check(pla)) return();
  1308.   if(fline==25)
  1309.     {
  1310.     fline=0;
  1311.     wait_space(pla);
  1312.     }
  1313.   if (fline==0)
  1314.     {
  1315.     SetAPen(ConPort,BLACKPEN);
  1316.     RectFill(ConPort,0L,0L,399L,199L);
  1317.     }
  1318.   pos=0;
  1319.   DText.FrontPen=PLAYERPEN(pla1);
  1320.   DText.IText=(UBYTE *)ship[shi1].name;
  1321.   PrintIText(ConPort,&DText,pos,fline*8L);
  1322.   pos+=IntuiTextLength(&DText);
  1323.   DText.FrontPen=WHITEPEN;
  1324.   DText.IText=(UBYTE *)" fires on ";
  1325.   PrintIText(ConPort,&DText,pos,fline*8L);
  1326.   pos+=IntuiTextLength(&DText);
  1327.   DText.FrontPen=PLAYERPEN(pla2);
  1328.   DText.IText=(UBYTE *)ship[shi2].name;
  1329.   PrintIText(ConPort,&DText,pos,fline*8L);
  1330.   pos+=IntuiTextLength(&DText);
  1331.   DText.FrontPen=WHITEPEN;
  1332.   DText.IText=(UBYTE *)":";
  1333.   PrintIText(ConPort,&DText,pos,fline*8L);
  1334.   pos+=IntuiTextLength(&DText);
  1335.   DText.IText=(UBYTE *)str;
  1336.   PrintIText(ConPort,&DText,pos,fline*8L);
  1337.   pos+=IntuiTextLength(&DText);
  1338.   DText.FrontPen=GREENPEN;
  1339.   fline++;
  1340.   }
  1341. tshipsummary(pla1,pla,shi)
  1342. int pla1;
  1343. int pla;
  1344. int shi;
  1345.   {
  1346.   int i;
  1347.   char name[30];
  1348.   if(!display_check(pla1)) return();
  1349.   screen2=SHIPOVERVIEW;showpla2=pla;show2=shi;
  1350.   SetAPen(ConPort,BLACKPEN);
  1351.   RectFill(ConPort,400L,120L,639L,199L);
  1352.   DText.FrontPen=PLAYERPEN(pla);
  1353.   DText.DrawMode |= INVERSVID;
  1354.   SetAPen(ConPort,PLAYERPEN(pla));
  1355.   RectFill(ConPort,400L,120L,639L,127L);
  1356.   strcpy(name,"Shipoverview:");
  1357.   strcat(name,ship[shi].name);
  1358.   DText.IText=(UBYTE *)name;
  1359.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,120L);
  1360.   DText.DrawMode &=~INVERSVID;
  1361.   DText.FrontPen=WHITEPEN;
  1362.   if(pla!=pla1 && pla1!=mode)
  1363.     {
  1364.     DText.IText=(UBYTE *)"Tf %  %%%";
  1365.     for(i=0;i<TASKNO;i++)
  1366.       if(task[pla][i].headed!=-1 && task[pla][i].arriving<=general.time
  1367.          && knowstar(pla1,task[pla][i].headed) && task[pla][i].ship_free[shi]>0)
  1368.       {
  1369.       if(task[pla][i].arriving>general.time) DText.DrawMode |= INVERSVID;
  1370.                                         else DText.DrawMode &=~INVERSVID;
  1371.       DText.IText[3]=(UBYTE)TASKCHAR(i);
  1372.       mstr(task[pla][i].ship_free[shi],DText.IText+6);
  1373.       PrintIText(ConPort,&DText,400L+80*(i/9),8*(i%9)+128L);
  1374.       }
  1375.     DText.FrontPen=GREENPEN;
  1376.     return();
  1377.     }
  1378.   DText.IText=(UBYTE *)"Tf% %%/%%";
  1379.   for(i=0;i<TASKNO;i++)
  1380.     if(task[pla][i].headed!=-1 && INTASK(pla,i,shi))
  1381.     {
  1382.     if(task[pla][i].arriving>general.time) DText.DrawMode |= INVERSVID;
  1383.                                       else DText.DrawMode &=~INVERSVID;
  1384.     DText.IText[2]=(UBYTE)TASKCHAR(i);
  1385.     rstr(task[pla][i].ship_free[shi],DText.IText+4);
  1386.     rstr(task[pla][i].ship_load[shi],DText.IText+7);
  1387.     PrintIText(ConPort,&DText,400L+80*(i/9),8*(i%9)+128L);
  1388.     }
  1389.   DText.DrawMode=JAM2;
  1390.   DText.FrontPen=GREENPEN;
  1391.   }
  1392. showhelp(pla)
  1393. int pla;
  1394.   {
  1395.   if(!display_check(pla)) return();
  1396.   SetAPen(ConPort,BLACKPEN);
  1397.   RectFill(ConPort,400L,0L,639L,39L);
  1398.   DText.FrontPen=GREENPEN;
  1399.   DText.IText=(UBYTE *)"G=Go on        c=Carry Ships  ";
  1400.   PrintIText(ConPort,&DText,400L,0L);
  1401.   DText.IText=(UBYTE *)"h=Hyperspace   b=Build Ship   ";
  1402.   PrintIText(ConPort,&DText,400L,8L);
  1403.   DText.IText=(UBYTE *)"e=Emigrate     p=Possess Plan.";
  1404.   PrintIText(ConPort,&DText,400L,16L);
  1405.   DText.IText=(UBYTE *)"k=Kill         d=Declaration  ";
  1406.   PrintIText(ConPort,&DText,400L,24L);
  1407.   DText.IText=(UBYTE *)"j=join Tf l=Land Tf n=Split Tf";
  1408.   PrintIText(ConPort,&DText,400L,32L);
  1409.   }
  1410. showstars(pla)
  1411. int pla;
  1412.   {
  1413.   int i;
  1414.   if(!display_check(pla)) return();
  1415.   screen1=STAROVERVIEW;
  1416.   SetAPen(ConPort,BLACKPEN);
  1417.   RectFill(ConPort,400L,40L,639L,119L);
  1418.   SetAPen(ConPort,PLAYERPEN(pla));
  1419.   RectFill(ConPort,400L,40L,639L,47L);
  1420.   DText.FrontPen=PLAYERPEN(pla);
  1421.   DText.DrawMode |= INVERSVID;
  1422.   DText.IText=(UBYTE *)"Staroverview";
  1423.   PrintIText(ConPort,&DText,520L-IntuiTextLength(&DText)/2,40L);
  1424.   DText.DrawMode &=~INVERSVID;
  1425.   DText.FrontPen=WHITEPEN;
  1426.   DText.IText=(UBYTE *)"% %%%/%%%/%%%";
  1427.   for(i=0;i<STARNO;i++)
  1428.     {
  1429.     if(CommData[pla].star[i].ruler==PLAYERNO) continue;
  1430.     if(CommData[pla].star[i].ruler<PLAYERNO) DText.FrontPen=PLAYERPEN(CommData[pla].star[i].ruler);
  1431.     if(CommData[pla].star[i].ruler==FIGHTING) DText.FrontPen=OTHERPEN;
  1432.     if(CommData[pla].star[i].ruler==UNINHABITED) DText.FrontPen=WHITEPEN;
  1433.     DText.DrawMode=JAM2;
  1434.     if(!knowstar(pla,i)) DText.DrawMode |= INVERSVID;
  1435.     DText.IText[0]= (UBYTE) ('A'+i);
  1436.     mstr(CommData[pla].star[i].totsize,DText.IText+2);
  1437.     mstr(CommData[pla].star[i].totpop,DText.IText+6);
  1438.     mstr(CommData[pla].star[i].totind,DText.IText+10);
  1439.     PrintIText(ConPort,&DText,400L+120*(i/(STARNO/2)),8*(i%(STARNO/2))+48L);
  1440.     }
  1441.   DText.DrawMode=JAM2;
  1442.   DText.FrontPen=GREENPEN;
  1443.   }
  1444. process_mouse(pla,x,y)
  1445. int pla;
  1446. int x;
  1447. int y;
  1448.   {
  1449.   int pla1,tas1,pla2,tas2,sta,shi1,shi2,shi3,p,i,j;
  1450.   /* Check star */
  1451.   for(sta=0;sta<STARNO;sta++) if(star[sta].y==y && star[sta].x*2==x)
  1452.     {
  1453.     starsummary(pla,sta);
  1454.     return();
  1455.     }
  1456.   /* Check for taskforce on main screen */
  1457.   for(sta=0;sta<STARNO;sta++) if(star[sta].y==y && star[sta].x*2+1==x) break;
  1458.   if(sta!=STARNO)
  1459.     {
  1460.     if(!knowstar(pla,sta))
  1461.       {
  1462.       starsummary(pla,sta);
  1463.       return();
  1464.       }
  1465.     pla2=-1;
  1466.     for(pla1=0;pla1<PLAYERNO;pla1++)
  1467.       for(tas1=0;tas1<TASKNO;tas1++)
  1468.         if(task[pla1][tas1].headed==sta && task[pla1][tas1].arriving<=general.time) pla2=pla1,tas2=tas1;
  1469.     if(pla2==-1)
  1470.       {
  1471.       starsummary(pla,sta);
  1472.       return();
  1473.       }
  1474.     for(pla1=0;pla1<PLAYERNO;pla1++)
  1475.       for(tas1=0;tas1<TASKNO;tas1++)
  1476.         if(task[pla1][tas1].headed==sta && task[pla1][tas1].arriving<=general.time && (pla1!=pla2 || tas1!=tas2))
  1477.           {
  1478.           starsummary(pla,sta);
  1479.           return();
  1480.           }
  1481.     tasksummary(pla,pla2,tas2);
  1482.     return();
  1483.     }
  1484.   /* Check for click on mapfield */
  1485.   if(x<50)
  1486.     {
  1487.     showstars(pla);
  1488.     return();
  1489.     }
  1490.   /* Check for planet in starsummary */
  1491.   if(screen1==STARSUMMARY && y>5 && y<10 && x>49)
  1492.     {
  1493.     p=(y-6)*2+(x>64);
  1494.     if(star[show1].planet[p].size>0)
  1495.       planetsummary(pla,show1,p);
  1496.     return();
  1497.     }
  1498.   /* Check for taskforce in starsummary */
  1499.   if(screen1==STARSUMMARY && x>52 && y>9 && y<14)
  1500.     {
  1501.     pla1=y-10;
  1502.     tas1=x-53;
  1503.     if(task[pla1][tas1].headed!=show1) return();
  1504.     tasksummary(pla,pla1,tas1);
  1505.     return();
  1506.     }
  1507.   /* Check for show all tasks in starsummary */
  1508.   if(screen1==STARSUMMARY && x<52 && y>9 && y<14)
  1509.     {
  1510.     pla1=y-10;
  1511.     showtasks(pla,pla1);
  1512.     return();
  1513.     }
  1514.   /* Check for star in starsummary */
  1515.   if(screen1==STARSUMMARY && x>49 && y==14)
  1516.     {
  1517.     sta=(x-50)/4+1;
  1518.     if (sta<8) starsummary(pla,sort[sta]);
  1519.     return();
  1520.     }
  1521.   /* Check for show shipsummary in tasksummary */
  1522.   if(screen2==TASKSUMMARY && x<70 && y>15)
  1523.     {
  1524.     shi2=0;
  1525.     for(shi1=0;shi1<SHIPNO;shi1++)
  1526.       if(task[showpla2][show2].ship_free[shi1]>0 ||
  1527.         (task[showpla2][show2].ship_load[shi1]>0 && (pla==showpla2||pla==mode))) shi2++;
  1528.     shi3=((shi2-1)/10)*10+y-15;
  1529.     shi2=0;
  1530.     for(shi1=0;shi1<SHIPNO;shi1++)
  1531.       {
  1532.       if(task[showpla2][show2].ship_free[shi1]>0 ||
  1533.         (task[showpla2][show2].ship_load[shi1]>0 && (pla==showpla2||pla==mode))) shi2++;
  1534.       if (shi3==shi2) break;
  1535.       }
  1536.     if(shi1==SHIPNO) return;
  1537.     shipsummary(pla,shi1);
  1538.     return();
  1539.     }
  1540.   /* Check for shipoverview */
  1541.   if(screen2==TASKSUMMARY && x>69 && y>15)
  1542.     {
  1543.     shi2=0;
  1544.     for(shi1=0;shi1<SHIPNO;shi1++)
  1545.       if(task[showpla2][show2].ship_free[shi1]>0 ||
  1546.         (task[showpla2][show2].ship_load[shi1]>0 && (pla==showpla2||pla==mode))) shi2++;
  1547.     shi3=((shi2-1)/10)*10+y-15;
  1548.     shi2=0;
  1549.     for(shi1=0;shi1<SHIPNO;shi1++)
  1550.       {
  1551.       if(task[showpla2][show2].ship_free[shi1]>0 ||
  1552.         (task[showpla2][show2].ship_load[shi1]>0 && (pla==showpla2||pla==mode))) shi2++;
  1553.       if (shi3==shi2) break;
  1554.       }
  1555.     if(shi1==SHIPNO) return;
  1556.     tshipsummary(pla,showpla2,shi1);
  1557.     return();
  1558.     }
  1559.   /* Check for click on shipname in planetsummary */
  1560.   if(screen2==PLANETSUMMARY && y==19)
  1561.     {
  1562.     if(star[show2].planet[showpla2].producing<SHIPNO)
  1563.       shipsummary(pla,star[show2].planet[showpla2].producing);
  1564.     return();
  1565.     }
  1566.   /* Check for click on Tf in Taskoverview */
  1567.   if(screen2==TASKOVERVIEW && y>15)
  1568.     {
  1569.     pla1=showpla2;
  1570.     tas1=((x-50)/10)*9+(y-16);
  1571.     tasksummary(pla,pla1,tas1);
  1572.     return();
  1573.     }
  1574.   /* Check for click on Tf in Shipoverview */
  1575.   if(screen2==SHIPOVERVIEW && y>15)
  1576.     {
  1577.     pla1=showpla2;
  1578.     tas1=((x-50)/10)*9+(y-16);
  1579.     if(task[pla1][tas1].ship_free[show2]==0 && pla1!=pla && pla!=mode) return();
  1580.     if(!INTASK(pla1,tas1,show2)) return();
  1581.     tasksummary(pla,pla1,tas1);
  1582.     return();
  1583.     }
  1584.   if(screen1==STAROVERVIEW && y>5 && y<14)
  1585.     {
  1586.     sta=((x-50)/15)*8+(y-6);
  1587.     starsummary(pla,sta);
  1588.     return();
  1589.     }
  1590.   if(y<4)
  1591.     {
  1592.     showhelp(pla);
  1593.     return();
  1594.     }
  1595.   }
  1596. planetsummary(pla1,sta,p)
  1597. int pla1;
  1598. int sta;
  1599. int p;
  1600.   {
  1601.   int pla2,cost;
  1602.   if(!display_check(pla1)) return();
  1603.   screen2=PLANETSUMMARY;
  1604.   show2=sta;
  1605.   showpla2=p;
  1606.   SetAPen(ConPort,BLACKPEN);
  1607.   RectFill(ConPort,400L,120L,639L,199L);
  1608.   if(sta<0 || sta>=STARNO) return();
  1609.   if(star[sta].planet[p].size<=0) return();
  1610.   if(!knowstar(pla1,sta)) return();
  1611.   pla2=star[sta].planet[p].ruler;
  1612.   if(pla2<PLAYERNO)  DText.FrontPen=PLAYERPEN(pla2);
  1613.   if(pla2==PLAYERNO) DText.FrontPen=WHITEPEN;
  1614.   SetAPen(ConPort,(long) DText.FrontPen);
  1615.   RectFill(ConPort,400L,120L,639L,127L);
  1616.   DText.DrawMode |= INVERSVID;
  1617.   DText.IText=(UBYTE *)"Star %(%%,%%)  Planet %       ";
  1618.   DText.IText[5]=(UBYTE) ('A'+sta);
  1619.   rstr(star[sta].x,DText.IText+7);
  1620.   rstr(star[sta].y,DText.IText+10);
  1621.   DText.IText[22]=(UBYTE) ('0'+p);
  1622.   PrintIText(ConPort,&DText,400L,120L);
  1623.   DText.DrawMode=JAM2;
  1624.   DText.FrontPen=WHITEPEN;
  1625.   DText.IText=(UBYTE *) "Size        :%%%";
  1626.   mstr(star[sta].planet[p].size,DText.IText+13);
  1627.   PrintIText(ConPort,&DText,400L,128L);
  1628.   DText.IText=(UBYTE *) "Population  :%%%";
  1629.   mstr(star[sta].planet[p].population,DText.IText+13);
  1630.   PrintIText(ConPort,&DText,400L,136L);
  1631.   DText.IText=(UBYTE *) "Industry    :%%%";
  1632.   mstr(star[sta].planet[p].industry,DText.IText+13);
  1633.   PrintIText(ConPort,&DText,400L,144L);
  1634.   DText.IText=(UBYTE *) "Building    :-";
  1635.   PrintIText(ConPort,&DText,400L,152L);
  1636.   if(star[sta].planet[p].producing<SHIPNO)
  1637.     {
  1638.     DText.IText=(UBYTE *) ship[star[sta].planet[p].producing].name;
  1639.     cost=ship[star[sta].planet[p].producing].techcost;
  1640.     }
  1641.   if(star[sta].planet[p].producing==MINING)
  1642.     {
  1643.     DText.IText=(UBYTE *) "MINING";
  1644.     cost=MCOST;
  1645.     }
  1646.   if(star[sta].planet[p].producing==INVESTING)
  1647.     {
  1648.     DText.IText=(UBYTE *) "INVESTING";
  1649.     cost=ICOST;
  1650.     }
  1651.   if(star[sta].planet[p].producing==RESEARCHING)
  1652.     {
  1653.     DText.IText=(UBYTE *) "RESEARCHING";
  1654.     cost=RCOST;
  1655.     }
  1656.   if(star[sta].planet[p].producing==DO_NOTHING)
  1657.     {
  1658.     DText.FrontPen=GREENPEN;
  1659.     return();
  1660.     }
  1661.   PrintIText(ConPort,&DText,504L,152L);
  1662.   DText.IText=(UBYTE *) "Cost        :%%% per Unit";
  1663.   mstr(cost,DText.IText+13);
  1664.   PrintIText(ConPort,&DText,400L,160L);
  1665.   DText.IText=(UBYTE *) "Average time:%%.%% Years";
  1666.   rstr(cost/star[sta].planet[p].industry,DText.IText+13);
  1667.   rstr(((cost*100)/star[sta].planet[p].industry)%100,DText.IText+16);
  1668.   PrintIText(ConPort,&DText,400L,168L);
  1669.   DText.IText=(UBYTE *) "Available   :Year %%%% (Est.)";
  1670.   qstr(general.time+(cost-star[sta].planet[p].ipoints+star[sta].planet[p].industry-1)/star[sta].planet[p].industry,DText.IText+18);
  1671.   PrintIText(ConPort,&DText,400L,176L);
  1672.   DText.FrontPen=GREENPEN;
  1673.   }
  1674. sortstars(sta)
  1675. int sta;
  1676.   {
  1677.   register i;
  1678.   int flag;
  1679.   sortsta=sta;
  1680.   for(i=0;i<STARNO;i++)
  1681.     {
  1682.     sort[i]=i;
  1683.     dis[i]=distance(sta,i);
  1684.     }
  1685.   flag=1;
  1686.   while(flag)
  1687.     {
  1688.     flag=0;
  1689.     for(i=0;i<STARNO-1;i++) if(dis[i]>dis[i+1])
  1690.       {
  1691.       flag=1;
  1692.       dis[i]   ^=dis[i+1];
  1693.       dis[i+1] ^=dis[i];
  1694.       dis[i]   ^=dis[i+1];
  1695.       sort[i]  ^=sort[i+1];
  1696.       sort[i+1]^=sort[i];
  1697.       sort[i]  ^=sort[i+1];
  1698.       /* Bet you didn't know that,did you ?                       */
  1699.       /* Exchanges sort[i] and sort[i+1], and dis[i] and dis[i+1] */
  1700.       /* Thanx for this algo,florian schwingenschloegel           */
  1701.       }
  1702.     }
  1703.   }
  1704.